package com.zsk.shop.enums;

/**
 * @author Ys
 * @date 2021年11月22日 16:38
 */
public enum EnumOrderStatus {

    PAY_NOT("待支付", "0"),

    PAY_SUCCESS("支付成功-待发货", "10"),

    DELIVERY_STATUS("支付成功-已发货", "20"),

    COMPLETE("已完成", "30"),

    CANCEL_ORDER("取消订单", "40"),
    ORDER_CANCEL_TIME("取消订单-未支付", "41"),
    CANCEL_ORDER_REFUND("取消订单-退款完成", "42"),

    CANCEL_PAY_NEED_REFUND("取消订单-支付完成需退款（退款后修改为退款完成）", "43"),
    ;

    private String name;
    private String code;

    EnumOrderStatus(String name, String code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public static String getNameByCode(String code) {
        EnumOrderStatus[] enums = EnumOrderStatus.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getCode().equals(code)) {
                return enums[i].getName();
            }
        }
        return "";
    }
}